
import 'package:flutter/material.dart';
import 'package:flutter_get_x/entity/ItemBar.dart';
import 'package:flutter_get_x/page/alarm/view.dart';
import 'package:flutter_get_x/page/bottle/view.dart';
import 'package:flutter_get_x/page/home/view.dart';
import 'package:flutter_get_x/page/mine/view.dart';
import 'package:flutter_get_x/page/work/view.dart';

import 'state.dart';
import 'package:get/get.dart';

class MainLogic extends GetxController {

  final MainSate state = MainSate();
  PageController pageController;

  @override
  void onInit() {
    pageController = PageController();
    _loadBottomBar();
    _loadPages();
    super.onInit();
  }

  @override
  onClose() {
    pageController.dispose();
    super.onClose();
  }

  _loadPages() {
    state.pageList.add(HomePage());
    state.pageList.add(BottlePage());
    state.pageList.add(WorkPage());
    state.pageList.add(AlarmPage());
    state.pageList.add(MinePage());
  }

  _loadBottomBar() {
    state.bottomItems.add(ItemBar(text: "首页", icon: Icons.home_outlined, selectedIcon: Icons.home));
    state.bottomItems.add(ItemBar(text: "更换", icon: Icons.add_box_outlined, selectedIcon: Icons.add_box));
    state.bottomItems.add(ItemBar(text: "巡检", icon: Icons.work_outline, selectedIcon: Icons.work));
    state.bottomItems.add(ItemBar(text: "告警", icon: Icons.alarm_outlined, selectedIcon: Icons.alarm));
    state.bottomItems.add(ItemBar(text: "我的", icon: Icons.settings_outlined, selectedIcon: Icons.settings));
  }
}